<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<input type="text" id="p" >
	<input type="submit" name="" value='提交' onclick="kj()">
</body>
<script type="text/javascript">
	function kj(){
		var p = document.getElementById('p');
		if (p.value == ""){
			alert('不能为空,请输入');
			//验证输入的是否为数字
		}else if(!/^[0-9]*$/.test(p.value)){
			alert('格式不正确,请重新输入');
		}else{
			alert('已提交');
		}
	}
</script>
</html>